package m.jclecai.com.fragment.klpk.pager;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;


import java.util.ArrayList;

import m.jclecai.com.R;
import m.jclecai.com.bean.klpk.bean.PokerBean;
import m.jclecai.com.view.klpk.PagerRecyclerAdapter;
import m.jclecai.com.view.klpk.Poker;

/**
 * Created by andy on 2017/6/6.
 * 顺子
 */

public class FlushFragment extends BasePagerFragment {


    @Override
    protected ArrayList<ArrayList<PokerBean>> initData() {

        setIndex(2);
        setItemAward(400);
        setSelectAllAward(33);

        mTvSelectedAllRules.setText(getSelectedAllRichText("任选数字,只要开出顺子即中奖33元"));

        //=======这里的话，我完成对数据的一个初始化，将123，234，这些顺子放入===========
        ArrayList<ArrayList<PokerBean>> mListData=new ArrayList<ArrayList<PokerBean>>();

        for(int i=1;i<13;i++){
            //12个顺子；
            ArrayList<PokerBean> pokerBeenList = new ArrayList<>();
            PokerBean pokerBean1=null;
            PokerBean pokerBean2=null;
            PokerBean pokerBean3=null;
            if(i<12){
                pokerBean1 = new PokerBean(null, i);
                pokerBean2 = new PokerBean(null, i+1);
                pokerBean3 = new PokerBean(null, i+2);

            }else if(i==12){
                pokerBean1=new PokerBean(null,i);
                pokerBean2=new PokerBean(null,i+1);
                pokerBean3=new PokerBean(null,1);
            }

            pokerBeenList.add(pokerBean1);
            pokerBeenList.add(pokerBean2);
            pokerBeenList.add(pokerBean3);

            mListData.add(pokerBeenList);
        }

        return mListData;
    }

    @Override
    public PagerRecyclerAdapter getMyAdapter() {
        return new MyAdapter(mListData);
    }

    @Override
    public RecyclerView.LayoutManager getLayoutManager() {
        return new GridLayoutManager(getActivity(),3){
            @Override
            public boolean canScrollVertically() {
                return false;
            }
        };
    }


    class MyAdapter extends PagerRecyclerAdapter{

        @Override
        public void onBindViewHolder(PagerRecyclerAdapter.ViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            //设置牌的间距；
            holder.mPokerGroup.setSpacing(22);
        }

        public MyAdapter(ArrayList<ArrayList<PokerBean>> listData) {
            super(listData);
        }

        @Override
        protected int getPokerCategory() {
            return Poker.TYPE_FLUSH;
        }

        @Override
        public int getItemLayout() {
            return R.layout.item_poker_flush;
        }
    }



    @Override
    public String getSelectAllTitle() {
        return "顺子包选";
    }
}
